﻿@* TypeVisibility: Internal *@
@model UrlHandlerIndexViewModel
@section PageTitle {
  Url Manager
}
@section Head {
}
@section Title {
  <h1>URL Manager</h1>
}
<div class="tabbable">
	<ul class="nav nav-tabs">
		<li class="active"><a href="#manage" data-toggle="tab">Manage</a></li>
		<li><a href="#notfound" data-toggle="tab">Not Founds</a></li>
	</ul>
	<div class="tab-content">
		<div class="tab-pane active" id="manage">
			<div class="row-fluid separator">
				<div class="btn-group pull-right">
					<a href="#editModal" role="button" class="btn btn-primary" data-toggle="modal"><i class="icon-white icon-plus"></i>Add new</a>	
				</div>
            </div>
			<div class="row-fluid">
				@(Html.Grid(m => m.UrlHandlers)
					  .AddClass("table")
					  .Columns(columns =>
							   {
								   columns.Column(x => x.UrlHandlerId).Hidden();
								   columns.Column(x => x.Url).SetDisplayName("URL");
								   columns.Column(x => x.StatusCode).SetDisplayName("Status Code");
								   columns.Column(x => x.RedirectUrl).SetDisplayName("Redirect To");
								   columns.Column(x => x.CreatedDate).Hidden();
								   columns.Column(x => x.CreatedByUserId).Hidden();
								   columns.Column(x => x.ModifiedDate).Hidden();
								   columns.Column(x => x.ModifiedByUserId).Hidden();
							   }))   
			</div>
		</div>
		<div class="tab-pane" id="notfound">
			<div class="row-fluid separator">
				<div class="btn-group pull-right">
					<a href="#" role="button" class="btn"><i class="icon-white icon-trash"></i>Clear</a>	
				</div>
            </div>
			<div class="row-fluid">
				@(Html.Grid(m => m.NotFounds)
					  .AddClass("table")
					  .Columns(columns =>
							   {
								   columns.Column(x => x.TrackNotFoundId).Hidden();
								   columns.Column(x => x.Date).SetRenderer(x => x.Date.Timago().ToHtmlString());
								   columns.Column(x => x.Url).SetDisplayName("URL");
								   columns.Column(x => x.Referrer);
								   columns.Column(x => x.Count);
								   columns.Column(x => x.UserId).Hidden();
							   }))
			</div>
		</div>
	</div>
</div>
@section BodyEnd {
	<div id="editModal" class="modal hide urlhandler-modal" tabindex="-1" role="dialog">
		@using (Html.BeginForm("Save", "UrlHandler", FormMethod.Post, new { id="editForm", @class = "form-horizontal" })) {
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
				<h3>ADD NEW</h3>
			</div>
			<div class="modal-body">
				<input type="hidden" id="urlHandlerId" name="urlHandlerId" />
				<div class="control-group">
					<label class="control-label" for="url">URL</label>
					<div class="controls">
						<input type="text" id="url" name="url" class="span6">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="statuscode">Redirect</label>
					<div class="controls">
						<select id="statuscode" name="statuscode">
							<option value="302">Found (302)</option>
							<option value="301">Permantent (301)</option>
							<option value="404">Not Found (404)</option>
						</select>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="redirecturl">To</label>
					<div class="controls">
						<input type="text" id="redirecturl" name="redirecturl" class="span6">
					</div>
				</div>
			</div>
			<div class="modal-footer">
				<button class="btn" data-dismiss="modal">Close</button>
				<button id="save" class="btn btn-primary">Save changes</button>
			</div>
		}
	</div>
	@*<script type="text/javascript">
	    $().ready(function() {
	        $('#save').click(function () {
	            var values = $('#editForm').serialize();
	            $.post($('#editForm').attr('action'), values, function (result) {
	            });
	        });
	    })
	</script>*@
}


